﻿using UnityEngine;
using System.Collections;

public class FloorCheck : MonoBehaviour {

	GameObject birdObject;
	//TextMesh debugText;
	Animator birdAnimator;
	// Use this for initialization
	void Start () {		
		this.birdObject = GameObject.Find ("MainBird");
		//this.debugText = (TextMesh)GameObject.Find ("DebugText").GetComponent(typeof(TextMesh));
		if (this.birdObject == null) {
			Debug.LogError("Bird not found");
		}
		this.birdAnimator = this.birdObject.GetComponent<Animator> ();

	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnCollisionEnter2D(Collision2D other) {

		//debugText.text = other.rigidbody.velocity.ToString ();
		//Debug.LogWarning ("Hit Collision " + other.relativeVelocity);
		if (other.collider.tag == "Player") {
			//this.birdAnimator.SetBool ("IsFlapping", false);
			if (other.rigidbody.velocity.y <= 0f) {
				this.birdAnimator.SetBool ("IsFlapping", false);
			}
		}
	}
}
